%% ——————————
% 【说明】：PLL仿真
%——————————


clc;clear;close all;

%% Input Signal

hold all

w = 2*pi;
phi_err = deg2rad(10);

Xa = @(t) sin(w*t);
Xb = @(t) sin(w*t+pi/2+phi_err);

t_ = 2*pi/w*[0:0.01:10];

% Generate Hall signal B
rng(666)
Xa_ = awgn(Xa(t_), 20, 'measured');
plot (t_, Xa_)

% Generate Hall signal B
rng(888)
Xb_ = awgn(Xb(t_), 20, 'measured');
plot (t_, Xb_)

%% PLL algorithm
s = tf("s");


 